Formius.Validator_Length = $.inherit(Formius.Validator_Abstract, {
	_messages: {
		MAX_LENGTH_ERROR: 'Не более {compare} символов',
		MIN_LENGTH_ERROR: 'Не менее {compare} символов',
		EQUAL_LENGTH_ERROR: 'Значение должно состоять из {compare} символов'
	},
	
	_isValid: function(value) {
		value = value || '';
		if (!('compare' in this._options)) {
			this._setCode('UNKNOWN_COMPARE');
		} else {
			var mode = this._options['mode'] || this.__self.LENGTH_MAX,
				compare = this._options['compare'];
			if (mode == this.__self.LENGTH_MIN && ('' + value).length < compare) {
				this._setCode('MIN_LENGTH_ERROR');
			} else if (mode == this.__self.LENGTH_MAX && ('' + value).length > compare) {
				this._setCode('MAX_LENGTH_ERROR');
			} else if (mode == this.__self.LENGTH_EQUAL && ('' + value).length != compare) {
				this._setCode('EQUAL_LENGTH_ERROR');
			} else {
				return true;
			}
		}
		return false;
	}
}, {
	LENGTH_MIN: 'min',
	LENGTH_MAX: 'max',
	LENGTH_EQUAL: 'equal'
});